<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_patrimonio.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="INVENTÁRIO 2012" />
				</h2>
				<hr />

				<p:messages id="msg" />
				
				<fieldset>

					<h:outputLink value="javascript:void(0)" onclick="dlgSetor.show();">
						<h:outputLabel value="Setor: " />
					</h:outputLink>
					<p:inputText id="setor" value="#{setorBean.setor.nome}" onclick="dlgSetor.show();" />&nbsp;&nbsp;
					
					<h:outputLabel value="Responsável: " />
					<h:outputText value="#{setorBean.setor.responsavel}" style="color: blue;" />
					
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<h:outputLabel value="Data de Execução: " />
					<h:outputText value="#{setorBean.setor.data.time}" style="color: blue;"> 
						<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
					</h:outputText><br /><br />
					
					<h:outputLabel value="Bloco: " />
					<h:outputText value="#{setorBean.setor.bloco.nome}" style="color: blue;" /><br /><br />
					
					<p:commandButton id="grava" value="ADD" action="formCadSetor.xhtml?faces-redirect=true" ajax="false" icon="ui-icon-disk">
						<f:ajax render="@form" />
					</p:commandButton>&nbsp;&nbsp;&nbsp;
					
					<p:button id="reset" type="reset" value="CANCELAR" /><br /><br />
					
					<h:outputLabel value="Para Cadastrar um novo setor click em ADD" style="color: blue" />

				</fieldset>
				
				<p:dataTable id="item" value="#{setorBean.itens}" var="item" rendered="#{not empty setorBean.setor.id}">
				
					<p:column headerText="Tombo">
						<h:outputText value="#{item.tombo}" />
					</p:column>
					
					<p:column headerText="Descrição">
						<h:outputText value="#{item.descricao}" />
					</p:column>
					
					<p:column headerText="Marca">
						<h:outputText value="#{item.marca}" />
					</p:column>
					
					<p:column headerText="Cor">
						<h:outputText value="#{item.cor}" />
					</p:column>
					
					<p:column headerText="Valor">
						<h:outputText value="#{item.valor_unit}" />
					</p:column>
					
					<p:column headerText="Est. do Bem">
						<h:outputText value="#{item.estado}" />
					</p:column>
					
					<p:column headerText="OBS">
						<h:outputText value="#{item.obs}" />
					</p:column>
				
				</p:dataTable>
				
			</h:form>
			
<!-- 			Dialogo para setor -->
			
			<p:dialog header="Setores" widgetVar="dlgSetor" model="true"
				width="500" showEffect="hide">
				<h:form id="form1">

					<p:outputPanel id="setores">

						<p:dataTable id="listSetor" value="#{setorBean.setores}" var="setor"
							paginator="true" selectionMode="single" rows="8" emptyMessage="Não Encontrado">

							<f:facet name="header">
								<h:outputText value="SETORES CADASTRADOS" />
							</f:facet>

							<p:column sortBy="#{setor.nome}" filterBy="#{setor.nome}"
								filterMatchMode="contains" headerText="Setor"
								style="width: 200px;">
								<h:commandLink value="#{setor.nome}" onclick="dlgSetor.hide()" id="setor">
									<f:setPropertyActionListener target="#{setorBean.setor}" value="#{setor}" />
								</h:commandLink>	
							</p:column>

							<p:column sortBy="#{setor.bloco.sigla}"
								filterBy="#{setor.bloco.sigla}" filterMatchMode="contains"
								headerText="Bloco" style="width: 100px;">
								<h:outputText value="#{setor.bloco.sigla}" />
							</p:column>

						</p:dataTable>

					</p:outputPanel>
				</h:form>
			</p:dialog>	
							
		</div>
		
	</ui:define>
</ui:composition>
</html>